#include"blockingqueue.c"
#include<unistd.h>
void* Consumer(void* arg)
{
  auto bq=(blockingqueue<int>*) arg;
  while(true)
  {
    int data=0;//输出型参数
    bq->Pop(data);
    cout<<"consumer:"<<data<<"当前个数:"<<bq->blockingqueue::q.size()<<endl;
    sleep(3);
  }
}
void* Producer(void* arg)
{
  auto bq=(blockingqueue<int>*) arg;
  while(true)
  {
    int data=rand()%100+1;
    bq->Push(data);
    cout<<"Producer:"<<data<<"当前个数:"<<bq->blockingqueue::q.size()<<endl;
    sleep(1);
  }
}
int main()
{
  srand((unsigned long)time(NULL));
  blockingqueue<int>* bq=new blockingqueue<int>();
  pthread_t c,p;
  pthread_create(&c,NULL,Consumer,bq);
  pthread_create(&p,NULL,Producer,bq);
  pthread_join(c,NULL);
  pthread_join(p,NULL);
  return 0;
}
